<template>
  <div>
    <ZgPage
      ref="page"
      title="发起流程"
      :pageOpt="{showAddBtn:false,showBatchBtn:false,showConditionBtn:true,showBtn:false}"
      @search="onSearch"
      @resetCondition="onResetCondition"
      @searchWithCondition="onSearchWithCondition"
    >
      <template slot="columns">
        <a-table-column :width="150" dataIndex="flowName" title="流程名称"></a-table-column>
        <a-table-column :width="150" dataIndex="flowCode" title="流程编号"></a-table-column>
        <a-table-column :width="150" dataIndex="flowDesc" title="流程描述"></a-table-column>
      </template>
      <template slot="condition">
        <Condition ref="condition"></Condition>
      </template>
    </ZgPage>
  </div>
</template>

<script>
import Condition from './Condition'
export default {
  components: {
    Condition
  },
  data () {
    return {

    }
  },
  methods: {
    onSearch (param) {
      this.$http.get('/zg-autoflow/workflowManage/getCanRunWorkflowList', param, data => {
        this.$refs.page.endSearch(
          {
            total: parseInt(data.total),
            list: data.records.map(t => {
              t.key = t.id
              return t
            })
          }
        )
      })
    },
    onResetCondition () {
      this.$refs.condition.reset()
    },
    onSearchWithCondition (param) {
      const condition = this.$refs.condition.getParam()
      this.$http.get('/zg-autoflow/workflowManage/getCanRunWorkflowList', Object.assign({}, param, condition), data => {
        this.$refs.page.endSearch(
          {
            total: parseInt(data.total),
            list: data.records.map(t => {
              t.key = t.id
              return t
            })
          }
        )
      })
    }
  }
}
</script>

<style scoped>

</style>
